<?php
namespace App\Admin\Renderable;

use App\Models\AdminFundNews;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class FundNewsTable extends LazyRenderable
{
    public function grid(): Grid
    {
        $fund_id = request()->get('id');

        return Grid::make(AdminFundNews::where('fund_id', $fund_id), function (Grid $grid) use ($fund_id) {
            $grid->column('id');
            $grid->column('title','标题');
            $grid->column('desc','简介');
            $grid->column('file_list','图片')->image('', 50, 50);
            $grid->column('show_time','显示时间');

            $grid->quickSearch(['title']);

            $grid->disableCreateButton(false);
            $grid->disableRowSelector();

            $grid->setResource("/fund/news");

            $grid->model()->setConstraints([
                'fund_id' => $fund_id,
            ]);

            $grid->paginate(10);
        });
    }
}
